package thread;

/**
 * @author DBX
 * @effect  获取线程信息的一组方法
 * @date 2021/8/31 0031 - 16:47
 */
public class ThreadInfoDemo {
    public static void main(String[] args) {
        Thread main = Thread.currentThread();

        String name = main.getName();
        System.out.println("name:\t"+name);

        long id = main.getId();
        System.out.println("id:\t"+id);

        int priority = main.getPriority();
        System.out.println("优先级:\t"+priority);

//        线程是否还活着
        boolean isAlive = main.isAlive();
        System.out.println("isAlive:\t"+isAlive);

//        线程是否为守护线程
        boolean isDaemon = main.isDaemon();
        System.out.println("isDaemon:\t"+isDaemon);

//        线程是否被中断了
        boolean isInterrupted = main.isInterrupted();
        System.out.println("isInterrupted:\t"+isInterrupted);
    }
}
